﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using RxxAdmin.Common;
using RxxAdmin.Service;

namespace RxxAdmin.Api.Controllers.System
{
    public class SysLoginController : ApiControllerBase
    {
        private readonly SysUserService _sysUserService;

        public SysLoginController(SysUserService sysUserService)
        {
            _sysUserService = sysUserService;
        }
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [AllowAnonymous]
        public async Task<JsonR> Login(SysUserLoginIn input)
        {
            return ResultCode.Success.JsonR(await _sysUserService.Login(input));
        }

        [HttpPost]
        [AllowAnonymous]
        public async Task<JsonR> Loginn(string a, string b) {
            await Task.CompletedTask;
            return ResultCode.Success.JsonR("");
        }
        /// <summary>
        /// 获取登录用户的信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<JsonR> GetUserInfo()
        {
            return ResultCode.Success.JsonR(await _sysUserService.GetUserInfo());
        }
    }
}
